package com.lt.setimage;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;


public class DialogHelper {


    public interface DialogCallback {
        /**
         * 确定
         */
        public void determine();

        /**
         * 取消
         */
        public void cancel();
    }



    /**
     * 两个按钮
     *
     * @param title
     * @param activity
     * @param message
     * @param ok
     * @param cancel
     * @param callback
     */
    public static void twoButtonDialog(Activity activity, String title,
                                       String message, String ok, String cancel,
                                       final DialogCallback callback) {


        View v = LayoutInflater.from(activity).inflate(R.layout.public_dialog,
                null);
        final AlertDialog ad = new AlertDialog.Builder(activity).create();
        ad.show();
        ad.setContentView(v);
        ((TextView) v.findViewById(R.id.textView_title)).setText(title);
        ((TextView) v.findViewById(R.id.textView_message)).setText(message);
        ((Button) v.findViewById(R.id.button_cancel)).setText(cancel);
        ((Button) v.findViewById(R.id.button_cancel))
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        callback.cancel();
                        ad.dismiss();
                    }
                });
        ((Button) v.findViewById(R.id.button_ok)).setText(ok);
        ((Button) v.findViewById(R.id.button_ok))
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        callback.determine();
                        ad.dismiss();
                    }
                });

    }


}
